-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix W.splitFileName "/\\?/a:" #220
Conversation
0449461
to
4cf5d70
Compare
4cf5d70
to
c394803
Compare
, null bs'' | ||
, Just (drive, rest) <- readDriveLetter file | ||
-> (dirSlash <> drive, rest) | ||
_ -> (dirSlash, file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is redundant? I'tll fall through to | otherwise
, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it does not fall through, the line is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I misread the code.
We have equivalence tests that compare this function with the old implementation. It's depressing that it wasn't caught. The quickcheck generators are not good enough and don't produce enough "odd data". I think one way forward is to implement the ABNF that I have here: https://github.com/hasufell/filepath/blob/16e5374620189b27eca1eed09642ec02b2222fc8/System/FilePath/Internal/Parser.hs#L157-L165 ...at least for the test suite and use that to generate windows filepaths. |
-- Otherwise, since s1 is a path separator, we might be in the middle of UNC path. | ||
, null bs' || maybe False isIncompleteUNC (readDriveUNC dirSlash) | ||
-> (fp, mempty) | ||
-- This handles inputs like "//?/A:" and "//?/A:foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trivia: //?/A:foo
is actually invalid in some sense... it's hard to interpret it. UNC paths are absolute, but A:foo
on its own is a relative directory (relative to current working dir on drive A
). The windows API probably won't care, but no such file can ever exist, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but filepath-1.4.2.2
does not mind to process //?/A:foo
even if it's complete nonsense.
I started this PR with thinking about properties of |
I pushed updated equivalence tests that now make use of the ABNF to generate more odd cases. Lots of new failures:
|
More specifically for This PR:
filepath-1.4.2.2:
|
The bug was in |
| isPathSeparator s1 | ||
, isPathSeparator s2 | ||
, Just (s3, s4, bs'') <- uncons2 bs' | ||
, s3 == _question |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is in fact a bug (although the old filepath behaves the same way):
ghci> System.FilePath.Windows.splitFileName "\\\\.\\a:foo"
("\\\\.\\","a:foo")
There are three UNC namespaces:
- file namespace:
//?/
- device namespace:
//./
- NT namespace
/??/
I'm still unsure whether fixing those bugs will cause more good than harm, but those are bugs.
Fixes #219.